package com.song.eureka.consumer.ribbon.hystrix.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.song.eureka.consumer.ribbon.hystrix.service.ConsumerService;

/**
 * 
 * @description : 
 * @date        : 2018-08-10 16:14
 * @author      : leoSong
 *
 */
@RestController
public class DcController {
  
    @Autowired
    ConsumerService consumerService;
  
    @Autowired
    RestTemplate restTemplate;
  
    /**
     * 去掉原来通过LoadBalancerClient选取实例和拼接URL的步骤，直接通过RestTemplate发起请求。
     * @date    : 2018-08-08 18:21
     * @author  : leoSong
     * @return
     */
    @GetMapping("/consumer")
    public String dc() {
//      String resp = restTemplate.getForObject("http://eureka-client/dc", String.class);
      String resp = consumerService.consumer();
      System.out.println(resp);
      return resp;
    }

}
